package com.gorkr.cronback.crontroller;


import com.gorkr.cronback.service.CronService;
import com.gorkr.cronback.vo.ReturnObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;

@RestController
@CrossOrigin
public class CronController {
    // todo： 错误处理

    @Autowired
    private CronService cronService;

    @RequestMapping("/cronParse")
    public ReturnObject cronParse(@RequestParam("cronString") String cronString) throws Exception {
        System.out.println("cronParse");

          // 普通的服务调用
          //  List<Date> dates = cronService.parseCronV2(cronString);

          // 采用观察者模式的服务调用
          Map<String,Object> res = cronService.parseCronV3(cronString);

        return new ReturnObject(res);
    }


}
